package com.lxy.aimin.auth.controller;


import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.lxy.aimin.auth.model.vo.MiniProgramLoginVO;
import com.lxy.aimin.auth.response.Result;
import com.lxy.aimin.auth.service.WxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/public/wx")
public class WxController {


    @Autowired
    WxService wxService;

    @GetMapping("/token")
    public Result<?> getToken(String code){
        StpUtil.login(10001);
        String tokenName = StpUtil.getTokenName();
        SaTokenInfo tokenValue = StpUtil.getTokenInfo();
        MiniProgramLoginVO miniProgramLoginVO = new MiniProgramLoginVO();
        miniProgramLoginVO.setTokenName(tokenName);
        miniProgramLoginVO.setTokenValue(String.valueOf(tokenValue));
        wxService.wxLogin(code);
        System.out.println(tokenName+":"+tokenValue);
        return Result.success(miniProgramLoginVO);
    }

}
